SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE Procedure [dbo].[SP_TDPRRE_GAST_U01]  
/*---------------------------------------------------------*/  
/*---Empresa              : OFISIS S.A.                  --*/  
/*---Cliente              : OFISIS S.A.           --*/  
/*---Sistema              : Tesoreria                    --*/  
/*---M«dulo               : Empresa                      --*/  
/*---Programa             : Inserci½n tdPRRE_GAST  --*/  
/*---Desarrollado por     : Carlos Marquez Escobar       --*/  
/*---Fecha Creaci«n       : 25/11/2004                   --*/  
/*---Base Datos           : Microsoft Sql Server         --*/  
/*---Versi«n              : 8.0                          --*/  
/*---Invoca a SP          :                              --*/  
/*---------------------------------------------------------*/  
/*-------------------------------------------------------*/  
/*---Modificado 1 por     : Maribel Julca Rodriguez      --*/  
/*---Fecha Modificaci©n   : 20/04/2005                   --*/   
/*---Detalle Modificaci©n : ingreso de los campos CO_USUA_CREA Y CO_USUA_MODI                           --*/  
/*-------------------------------------------------------*/  
/*---------------------------------------------------------*/  
/*---Comentarios                                         --*/  
/*---                                                    --*/  
/*---                                                    --*/  
/*---------------------------------------------------------*/  
  
/*---------------------------------------------------------*/  
/*---Drop Proc SP_TDPRRE_GAST_U01                        --*/  
/*---Grant all on SP_TDPRRE_GAST_U01 to public           --*/   
/*---------------------------------------------------------*/  
@ISCO_EMPR		TD_VC_002, 
@ISCO_USUA		TD_VC_008,   
@INNU_PRRE_GAST	TD_VC_010,   
@IDFE_PRRE_GAST	TD_DT_001,  
@INNU_CORR_SGTE	TD_IN_001,  
@ISCO_UNID_CNTB	TD_VC_003,    
@ISTI_ENTI		TD_VC_001,   
@ISCO_ENTI		TD_VC_020,  
@ISDE_ENTI		TD_VC_100,   
@ISCO_TIPO_DOCU	TD_VC_003,  
@ISNU_DOCU		TD_VC_020,  
@INFA_CAMB_DOCU	TD_NU_015_006,   
@INFA_CAMB_EXTR	TD_NU_015_006,   
@ISCO_MONE		TD_VC_003,  
@ISCO_TIOP_PROV	TD_VC_003,  
@INIM_BRUT_AFEC	TD_NU_016_004,  
@INIM_BRUT_INAF	TD_NU_016_004,  
@ISCO_IMP1		TD_VC_003,  
@INPC_IMP1		TD_NU_009_004,  
@INIM_IMP1		TD_NU_016_004,  
@ISCO_IMP2		TD_VC_003,  
@INPC_IMP2		TD_NU_009_004,  
@INIM_IMP2		TD_NU_016_004,  
@ISCO_IMP3		TD_VC_003,  
@INPC_IMP3		TD_NU_009_004,  
@INIM_IMP3		TD_NU_016_004,  
@INIM_SUBT_TOTA	TD_NU_016_004,  
@INIM_DOCU		TD_NU_016_004,   
@ISFE_DOCU		TD_DT_001,   
@IFFE_REGI_COMP	TD_DT_001,  
@INIM_CONV		TD_NU_016_004,  
@ISCO_TIPO_OPER	TD_VC_003,   
@ISCO_CNTA_EMPR	TD_VC_020,  
@ISDE_OBSE_DETA	TD_VC_100,  
@ISTI_AUXI		TD_VC_001,   
@ISCO_AUXI_EMPR	TD_VC_020,  
@ISCO_ORDE_SERV	TD_VC_020,  
@ISNU_IMPO		TD_VC_020
	As
declare 
@VNNU_CORR TD_IN_001,  
@VSST_PROV_AUTO TD_VC_001  
  
BEGIN TRAN  
  
	If @INIM_IMP1 < 0   
		Select @INIM_IMP1 = Abs(@INIM_IMP1), @INIM_IMP2 = Abs(@INIM_IMP2), @INIM_IMP3 = Abs(@INIM_IMP3)  
	
	Update  TDPRRE_GAST  
	Set CO_UNID_CONC = @ISCO_UNID_CNTB,   
		FA_CAMB_DOCU = @INFA_CAMB_DOCU,   
		FA_CAMB_EXTR = @INFA_CAMB_EXTR,   
		CO_MONE = @ISCO_MONE, CO_TIOP_PROV = @ISCO_TIOP_PROV,   
		IM_BRUT_AFEC = @INIM_BRUT_AFEC, IM_BRUT_INAF = @INIM_BRUT_INAF,   
		CO_IMP1 = @ISCO_IMP1, PC_IMP1 = @INPC_IMP1, IM_IMP1 = @INIM_IMP1,   
		CO_IMP2 = @ISCO_IMP2, PC_IMP2 = @INPC_IMP2, IM_IMP2 = @INIM_IMP2,   
		CO_IMP3 = @ISCO_IMP3, PC_IMP3 = @INPC_IMP3, IM_IMP3 = @INIM_IMP3,   
		IM_DOCU = @INIM_DOCU, FE_DOCU = @ISFE_DOCU, IM_CONV = @INIM_CONV,   
		CO_TIPO_OPER = @ISCO_TIPO_OPER, CO_CNTA_EMPR = @ISCO_CNTA_EMPR,   
		DE_OBSE = @ISDE_OBSE_DETA, TI_AUXI_EMPR = @ISTI_AUXI,   
		CO_CENT_COST = @ISCO_AUXI_EMPR, CO_ORDE_SERV = @ISCO_ORDE_SERV,  
		TI_ENTI = @ISTI_ENTI,   
		CO_ENTI = @ISCO_ENTI,  
		DE_ENTI = @ISDE_ENTI,   
		CO_TIPO_DOCU = @ISCO_TIPO_DOCU,  
		NU_DOCU_PROV = @ISNU_DOCU,  
		NU_IMPO = @ISNU_IMPO,
		CO_USUA_MODI = @ISCO_USUA,
		FE_USUA_MODI = GETDATE()  
	Where	CO_EMPR = @ISCO_EMPR  
	 And	NU_PRRE_GAST = @INNU_PRRE_GAST  
	 And	FE_PRRE_GAST = @IDFE_PRRE_GAST  
	 And	NU_CORR_GAST = @INNU_CORR_SGTE   
	
	
	IF (@@ERROR != 0)  
	BEGIN   
		RAISERROR 20001 'ERROR DE INSERCION'  
		ROLLBACK TRAN  
		RETURN  
	END  
  
COMMIT TRAN  
/*--------------------------- Fin -------------------------------- */


GO
